package com.x.crm.dao;

import com.x.crm.model.FollowReach;
import com.x.framework.dao.BaseDao;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository
public class FollowReachDao extends BaseDao{


	private final static String baseSelectFollowReachListSql = "SELECT * FROM  CRM_FOLLOW_REACH  I " +
			"WHERE 1=1 ";

	public List<FollowReach> selectFollowReachList(FollowReach followReach) throws Exception {
		StringBuilder sb = new StringBuilder(baseSelectFollowReachListSql);
		List<Object> params = new ArrayList<Object>();
		searchBasicCondition(followReach, sb, params);
		sb.append(" ORDER BY I.REACH_CREATE_TIME DESC" );
		return this.queryForList(sb.toString(), FollowReach.class, params, followReach);
	}


	private void searchBasicCondition(FollowReach followReach, StringBuilder sb, List<Object> params) {
		if (this.isString(followReach.getIntentionId())) {
			sb.append("AND I.INTENTION_ID = ? ");
			params.add(followReach.getIntentionId());
		}
	}


}
